Imports System.Web.Security.FormsAuthentication


Namespace Workflow


    Partial Class Login
        Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

        End Sub
        Protected WithEvents chkRememberMe As System.Web.UI.WebControls.CheckBox


        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub

#End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Page.IsPostBack Then Exit Sub

            SignOut()

            ddUser.DataSource = CUser.Cache
            ddUser.DataBind()
            ddUser.Items.Insert(0, New ListItem(""))
        End Sub


        Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
            If ddUser.SelectedIndex < 1 Then
                litMessage.Text = "Select a user"
                Exit Sub
            End If

            Dim user As CUser = CUser.Cache.GetById(ddUser.SelectedValue)
            If user.UserPassword <> txtPassword.Text Then
                litMessage.Text = "Invalid password"
                Exit Sub
            End If

            CSession.UserId = user.UserId 'Default search filter
            RedirectFromLoginPage(user.UserId, True)
        End Sub
    End Class

End Namespace
